package com.huawei.appmarket.service.settings.card;

import android.content.Context;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwSwitch;
import java.util.Locale;
import o.ceo;
import o.cgz;
import o.der.d;
import o.der.f;
import o.Logger;
import o.egn;
import o.egn$d;
import o.evk;

public class SettingRecommendCard extends BaseSettingCard implements OnCheckedChangeListener, egn$d {
    private HwSwitch ˊ;
    private View ॱ;

    public SettingRecommendCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        super.ˏ(view);
        this.ˊ = (HwSwitch) view.findViewById(d.ˇ);
        this.ॱ = view.findViewById(d.ʾᐝ);
        TextView textView = (TextView) this.ॱ.findViewById(d.ʽʻ);
        ((TextView) this.ॱ.findViewById(d.ʽʼ)).setText(f.ˋﾟ);
        textView.setText(f.ˋﾞ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        boolean z = true;
        super.ˏ(cardBean);
        this.ˊ.setEnabled(true);
        if (Logger.ˎ()) {
            Logger.ˏ("SettingRecommendCard", "setData: switchStatus:" + ceo.ˎ().ॱ());
        }
        HwSwitch hwSwitch = this.ˊ;
        if (ceo.ˎ().ॱ() != 1) {
            z = false;
        }
        hwSwitch.setChecked(z);
        this.ˊ.setOnCheckedChangeListener(this);
    }

    private void ˊ(boolean z) {
        if (Logger.ˎ()) {
            Logger.ˏ("SettingRecommendCard", "turnSwitch: " + z);
        }
        this.ˊ.setOnCheckedChangeListener(null);
        this.ˊ.setChecked(z);
        this.ˊ.setOnCheckedChangeListener(this);
    }

    private void ˋ(int i) {
        boolean z = ceo.ˎ().ॱ() == 1;
        if (Logger.ˎ()) {
            Logger.ˏ("SettingRecommendCard", String.format(Locale.ENGLISH, "changeViewStatusByServer: responseCode:%s oldSwitchStatus:%s isChecked:%s", new Object[]{Integer.valueOf(i), Integer.valueOf(r3), Boolean.valueOf(this.ˊ.isChecked())}));
        }
        if (this.ˊ.isChecked() != z) {
            ˊ(z);
        }
        ˏ(true);
        if (i == 3) {
            evk.ˋ(this.ʼॱ, this.ʼॱ.getString(f.ʻʽ), 0).ˋ();
        }
    }

    public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
        int i = 0;
        ˏ(false);
        if (z) {
            i = 1;
        }
        egn.ˎ().ˊ(i, this);
    }

    private void ˏ(boolean z) {
        this.ˊ.setEnabled(z);
        this.ॱ.setAlpha(z ? 1.0f : 0.3f);
    }

    public void ˏ(int i) {
        ˋ(i);
    }
}
